function mooseRespawn( groupname )
	if groupname ~= nil then
		local plane = SPAWN:New( tostring(groupname) )
		plane:Spawn()
	end
end

local groups = { "ColdWar", "AG-1", "BASE", "Fuel-1", "Fuel-2",
				 "JTAC-1", "RED Helo","Yujin",
				}

for i, v in ipairs(groups) do
	mooseRespawn(v)
end

-- 设置靶机配置
trigger.action.setUserFlag("bajinumber", 1)
trigger.action.setUserFlag("bajitype", 1)

local bajinumber = trigger.misc.getUserFlag("bajinumber")

BajiInit = SPAWN:New("Baji")
			:InitRandomizeTemplatePrefixes("Baji Template #")
			:OnSpawnGroup( function(group)
					MESSAGE:New("靶机已经刷新, 机型:" .. tostring(group:GetTypeName()) .. 
						".\n数量设置: " .. tostring(bajinumber), 10, "空战训练设置", true):ToAll()
					local PatrolZone = ZONE:New( "Baji" )
					local AICapZone = AI_CAP_ZONE:New( PatrolZone, 1828, 6096, 500, 600, "BARO")
					local EngageZoneGroup = GROUP:FindByName("Baji Engage Zone")
					local EngageZone = ZONE_POLYGON:New( "Baji Engage Zone", EngageZoneGroup)
					AICapZone:SetControllable(group)
					AICapZone:SetEngageZone(EngageZone)
					AICapZone:__Start(1)
				end
				)
BajiInit:Spawn()

Yujin